<script src="${request.getContextPath()}/appBord/jtopo/jtopo-min.js" type="text/javascript"></script>
<script src="${request.getContextPath()}/appBord/jtopo/toolbar.js" type="text/javascript"></script>
<script src="${request.getContextPath()}/appBord/jtopo/jtop-util.js" type="text/javascript"></script>
<script type="text/javascript">

    jtopoUtil.init("ID${PUUID}","${request.getContextPath()}/appBord/bg.jpg");

    var  canvas = jtopoUtil.canvas;
    var scene = jtopoUtil.scene;
    freshBoard();
    jtopoUtil.paint(false);

    function freshBoard(){
        $.getJSON("${request.getContextPath()}/appBordNodeMonitor/index?boardId=${PUUID}",function(rst){
            scene.clear()
            var container =  rst.container
            var containerNodes = rst.containerNodes
            var nodeSingle = rst.nodeSingle
            var appBordType =  rst.appBordType
            var nodeLine = rst.nodeLine
            var alarmNodes = rst.alarmNodes
            var typeColorMap =  rst.typeColorMap
            var appBordTypeList =  rst.appBordTypeList

            $.each(container,function(i,cont){
               // console.log(cont)
                var ctName = cont.groupName || cont.groupNo
                var ctObject = jtopoUtil.addContainer(ctName);
                $.each(containerNodes[cont.groupNo],function(ii,node){
                    var nodeKey = node.nodeName||node.nodeNo
                    var aNode = jtopoUtil.addNode(node.nodeNo,nodeKey,node.x,node.y,
                        basePath+"/"+node.nodeImg ,typeColorMap[nodeKey] ,ctObject,
                        node.width||0,node.height||0,node.actionUrl,${fullScreen?:false});

                    if(node.alarmNo !=null && node.alarmNo != "" ){
                        jtopoUtil.addAlarm(aNode,
                                typeColorMap[nodeKey],
                                alarmNodes[nodeKey]["alarmColor"],
                                alarmNodes[nodeKey]["alarmInfo"],
                                alarmNodes[nodeKey]["alarmFlash"]||0  );
                    }
                })
            })

            $.each(nodeSingle,function(i,node){
                var nodeKey = node.nodeName ||node.nodeNo
                var nodeS = jtopoUtil.addNode(node.nodeNo,nodeKey, node.x , node.y ,
                    "${request.getContextPath()}/"+node.nodeImg,typeColorMap[nodeKey],null ,
                    node.width||0,node.height||0,node.actionUrl,${fullScreen?:false});
                if(node.alarmNo !=null && node.alarmNo != "" ){
                    jtopoUtil.addAlarm(nodeS,
                            typeColorMap[nodeKey],
                            alarmNodes[nodeKey]["alarmColor"],
                            alarmNodes[nodeKey]["alarmInfo"],
                            alarmNodes[nodeKey]["alarmFlash"]||0  );
                }
            })

            $.each(nodeLine,function(i,line){
                jtopoUtil.addLink(line["from"] ,line.to,line.line);
            })

            $.each(appBordTypeList,function(i,legend){
                var yadd =50;
                jtopoUtil.addLegend(legend.typeName||legend.typeNo,80,(1+i)*yadd,legend.typeColor);
            })

        })
    }
</script>